#include <bits/stdc++.h>
using namespace std;

class Solution {
public:
    bool searchMatrix(vector<vector<int>>& matrix, int target) {
        int row = matrix.size();
        int col = matrix[0].size();
        int n = row * col;
        int left = 0; int right = n-1;
        while(left <= right){
            int mid = (left+right)>>1;
            int i = mid/col; int j=mid%col;
            if(matrix[i][j] == target) return true;
            else if(matrix[i][j] > target) right = mid-1;
            else if(matrix[i][j] < target) left = mid + 1;
        }
        return false;
    }
};

int main(){

}